package com.qingding.view;

import android.app.Service;
import android.content.Context;
import android.graphics.Color;
import android.graphics.Paint;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.CheckBox;
import android.widget.EditText;
import android.widget.LinearLayout;

import com.qingding.R;

/**
 * Created by Administrator on 2018-01-07.
 */
//自定义的线性布局
public class Comment_item extends LinearLayout {
    //构造方法
    public Comment_item(Context context) {
        super(context);
        //创建一个LayoutInflater实例
        LayoutInflater layoutInflater=(LayoutInflater) context.getSystemService(Service.LAYOUT_INFLATER_SERVICE);
        //然后将commen_item.xml所表示的布局加载进来,也就是一个复选框和一个编辑框
        View view=layoutInflater.inflate(R.layout.commen_item,this,true);
        //然后获取到这两个组件，并且这两个组件不在可以更改
        final CheckBox comment_check=(CheckBox) view.findViewById(R.id.comment_check);
        final EditText comment_content=(EditText)view.findViewById(R.id.comment_content);
        //为将复选框设置时间监听器
        comment_check.setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View v) {
                if (comment_check.isChecked()){
                    comment_content.setTextColor(Color.rgb(169,183,198));
                    comment_content.getPaint().setFlags(Paint. STRIKE_THRU_TEXT_FLAG|Paint.ANTI_ALIAS_FLAG);
                }else {
                    comment_content.setTextColor(Color.rgb(0,0,0));
                    comment_content.getPaint().setFlags(Paint.ANTI_ALIAS_FLAG);
                }

            }
        });
    }

}
